package com.zzy.springbootdemo.design_01_factory.spring.context;

import com.zzy.springbootdemo.design_01_factory.spring.common.Constants;
import com.zzy.springbootdemo.design_01_factory.spring.service.RewardSpringService;
import com.zzy.springbootdemo.design_01_factory.spring.service.impl.ECardRewardSpringService;
import com.zzy.springbootdemo.design_01_factory.spring.service.impl.MaterialRewardSpringService;
import com.zzy.springbootdemo.design_01_factory.spring.service.impl.VirtualRewardSpringService;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.HashMap;
import java.util.Map;

/**
 * Spring工厂方法2
 */
@Configuration
public class RewardContext {

    /**
     * 利用Spring依赖注入的第一种方式：利用
     * @param eCardRewardSpringService
     * @param materialRewardSpringService
     * @param virtualRewardSpringService
     * @return
     */
    @Bean
    public Map<Constants.REWARD, RewardSpringService> getRewardMap(ECardRewardSpringService eCardRewardSpringService,
                                                                   MaterialRewardSpringService materialRewardSpringService,
                                                                   VirtualRewardSpringService virtualRewardSpringService){
        Map<Constants.REWARD,RewardSpringService> rewardFactoryMap = new HashMap<>(8);
        rewardFactoryMap.put(Constants.REWARD.ECARD_REWORD,eCardRewardSpringService);
        rewardFactoryMap.put(Constants.REWARD.MATERIAL_REWOD,materialRewardSpringService);
        rewardFactoryMap.put(Constants.REWARD.VIRTUAL_REWORD,virtualRewardSpringService);
        return rewardFactoryMap;
    }

}
